package com.zaofan.dao;

import java.sql.SQLException;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.zaofan.bean.ShopCategory;
import com.zaofan.dao.base.DaoSupportImpl;

public class ShopCategoryDao extends DaoSupportImpl<ShopCategory> {

	public List<ShopCategory> findByShopIdAndSort(int shopId, int sort_b, int sort_e) {
		try {
			String sql = "select * from " + ShopCategory.class.getSimpleName().toLowerCase() + " where shopId = "
					+ shopId + " and sort >= " + sort_b + " and sort <= " + sort_e + " order by sort asc";
			System.err.println(sql);
			QueryRunner runner = new QueryRunner(getDataSource());
			return runner.query(sql, new BeanListHandler<>(ShopCategory.class));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}

}
